package net.wapproject.action;

import java.util.List;

import net.wapproject.bean.BaseObject;
import net.wapproject.bean.Category;
import net.wapproject.bean.Game;
import net.wapproject.bean.Pagination;
import net.wapproject.bo.ICategoryBO;
import net.wapproject.bo.IGameBO;
import net.wapproject.bo.IUserBO;

import org.apache.log4j.Logger;

/**
 * 
 * @author HoangAnh
 * 
 */

public class HomeAction extends BaseAction {

	private static final long serialVersionUID = -5025514697405256918L;
	Logger log = Logger.getLogger(HomeAction.class);
	private IUserBO userBo;
	private ICategoryBO categoryBo;
	private IGameBO gameBo;
	private List<Category> categoryList; 
	private Game game;
	private Integer gameId;
	private List<Game> gameList;
	private Integer categoryId;
	
	public String homePage() {
		categoryList = categoryBo.getParentCategory();
		
		for (int i = 0; i < categoryList.size(); i++) {
			List<Game> games = gameBo.getGameListByCategoryRoot(categoryList.get(i).getId());
			categoryList.get(i).setGames(games);
		}
		
		return SUCCESS;
	}
	
	
	public String gameDetails() {
		//gameBo.updateTotalView(gameId);
		game = gameBo.getGameByGameId(gameId);
		return SUCCESS;
	}
	
	public String gameListBycategoryRoot() {
		Pagination pagination = new Pagination();
		pagination.setSearchId(categoryId);
		pagination.setPageNumber(pageNumber);
		pagination.setPageSize(BaseObject.PAGE_SIZE);
		
		return SUCCESS;
	}
	
	public String gameListByCategory() {
		return SUCCESS;
	}
	
	/**
	 * @return the categoryList
	 */
	public List<Category> getCategoryList() {
		return categoryList;
	}

	/**
	 * @param categoryList the categoryList to set
	 */
	public void setCategoryList(List<Category> categoryList) {
		this.categoryList = categoryList;
	}

	
	public IUserBO getUserBo() {
		return userBo;
	}

	public void setUserBo(IUserBO userBo) {
		this.userBo = userBo;
	}

	public ICategoryBO getCategoryBo() {
		return categoryBo;
	}

	public void setCategoryBo(ICategoryBO categoryBo) {
		this.categoryBo = categoryBo;
	}

	public IGameBO getGameBo() {
		return gameBo;
	}

	public void setGameBo(IGameBO gameBo) {
		this.gameBo = gameBo;
	}


	/**
	 * @return the game
	 */
	public Game getGame() {
		return game;
	}


	/**
	 * @param game the game to set
	 */
	public void setGame(Game game) {
		this.game = game;
	}


	/**
	 * @return the gameId
	 */
	public Integer getGameId() {
		return gameId;
	}


	/**
	 * @param gameId the gameId to set
	 */
	public void setGameId(Integer gameId) {
		this.gameId = gameId;
	}
}
